_NS_OOP_BEGIN



template< class T >
ResourceLoader&
ResourceLoader::operator>> (T& r_data)
{
	_inStream >> r_data;
	return *this;
}



template< class T >
ResourceLoader&
ResourceLoader::operator>> (Ptr< T >& rp_data)
{
	QString refName;
	_inStream >> refName;
	if (refName == "NULL") {
		rp_data.setNull ();
		return *this;
	}
	rp_data = ResourceLoader ().loadObject (refName).cvt< T > ();
	return *this;
}



template< class T >
ResourceLoader&
ResourceLoader::operator>> (std::complex< T >& r_val)
{
	T real, imag;
	(*this) >> real >> imag;
	r_val = std::complex< T > (real, imag);
	return *this;
}



template< class T1, class T2 >
ResourceLoader&
ResourceLoader::operator>> (std::pair< T1, T2 >& r_val)
{
	*this >> r_val.first >> r_val.second;
	return *this;
}



template< class T, class _ALLOC >
ResourceLoader&
ResourceLoader::operator>> (std::vector< T, _ALLOC >& r_val)
{
	size_t nElems;
	*this >> nElems;
	r_val.resize (nElems);
	for (size_t i = 0; i < nElems; ++i)
		*this >> r_val[i];
	return *this;
}



template< class T, class _ALLOC >
ResourceLoader&
ResourceLoader::operator>> (std::set< T, _ALLOC >& r_val)
{
	size_t nElems;
	*this >> nElems;
	for (size_t i = 0; i < nElems; ++i) {
		T elem;
		*this >> elem;
		r_val.insert (elem);
	}
	return *this;
}



template< class T1, class T2, class _PR, class _ALLOC >
ResourceLoader&
ResourceLoader::operator>> (std::map< T1, T2, _PR, _ALLOC >& r_val)
{
	size_t nElems;
	*this >> nElems;
	for (size_t i = 0; i < nElems; ++i) {
		_T1 key;
		_T2 val;
		*this >> key >> val;
		r_val[key] = val;
	}
	return *this;
}




template< class T >
void
ResourceLoader::readArray (T* data, size_t count)
{
	_inStream.readRawData ((char*) data, sizeof (T) * count);
}



template< class T, class _ALLOC >
void
ResourceLoader::readSimpleVector (std::vector< T, _ALLOC >& r_vector)
{
	size_t count;
	(*this) >> count;
	r_vector.resize (count);
	readArray (&r_vector[0], count);
}



_NS_OOP_END